#include "string"
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "time.h"
#include "EventPump.h"
#include "MasterThread.h"
#include "TimeLib.h"

using namespace std;
MasterThread* pMain;
class STask : public Task
{
public:
	int Run();
};
int index = 0;
int STask::Run()
{
	index++;
	printf("MultiWork%d\n",index);
	STask* pTask = new STask;
	struct timeval t;
	gettimeofday(&t,NULL);
	t.tv_sec += 0;
	t.tv_usec+= 100*1000;
	if(t.tv_usec>1000*1000){
		t.tv_usec %= 1000*1000;
		t.tv_sec += 1;
	}
	pTask->SetTime(&t);
	pMain->InsertTask(pTask);
	return 0;
}


//int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpStr,int nShow)
int main(int argc,char** argv)
{
	EventPump * pEventPump = new EventPump();
	srand(time(NULL));
	pMain = new MasterThread(pEventPump);
	pMain->SetWorkerCount(4);
	pMain->Create();
	STask* pTask = new STask;
	struct timeval t={1,0};
	pTask->SetTime(&t);
	pMain->InsertTask(pTask);
	int index;
	cin>>index;		
	//CreateUI(hInstance, NULL);
    //pWorld->MainLoop();
    return 0;
}
